home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 8.1 KB | 223 lines | [TEXT/MPS ] |
- // UScroller.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __USCROLLER__
- #define __USCROLLER__
-
- // MacApp
-
- #ifndef __UGEOMETRY__
- #include "UGeometry.h"
- #endif
-
- #ifndef __UVIEW__
- #include "UView.h"
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TDocument;
- class TScrollerScrollBar;
- class TToolboxEvent;
-
-
- //----------------------------------------------------------------------------------------
- // TScroller: A view which can "scroll" its contents by translating coordinates.
- //----------------------------------------------------------------------------------------
-
- class TScroller : public TView
- {
- MA_DECLARE_CLASS;
-
- public:
- //------------------------------------------------------------------------------------
- // Creation/Destruction Methods
- //------------------------------------------------------------------------------------
-
- TScroller();
- // Constructor
-
- void IScroller(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- const VPoint& itsMax,
- Boolean wantHorzSBar,
- Boolean wantVertSBar);
- // Called to initialize a scroller procedurally.
-
- virtual void CreateScrollBar(VHSelect itsDirection);
- // Called to create a scrollbar in 'itsDirection'.
-
- virtual TObject* Clone();
- // calls Inherited::Clone and then clones owned objects
-
- virtual ~TScroller();
- // If there are attached scrollbars frees them before calling Inherited::Free.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream); // override
-
- virtual void WriteFields(TStream* aStream); // override
-
- //------------------------------------------------------------------------------------
- // SubView Management Methods
- //------------------------------------------------------------------------------------
-
- virtual void DoPostCreate(TDocument* itsDocument);
- // Called in a post-order traversal of a newly-created view hierarchy
-
- virtual void AddedASubView(TView* theSubView);
- // Calls Inherited::AddedASubView and then calls 'theSubView' to BeInScroller passing
- // this as the scroller to be in.
-
- virtual void RemovedASubView(TView* theSubView);
- // Calls BeInScroller with a parameter of NULL, for 'theSubView', before calling
- // Inherited::RemovedASubView.
-
- virtual void ForceRedraw();
- // Invalidates the entire view forcing a redraw.
-
-
- //------------------------------------------------------------------------------------
- // Size Methods
- //------------------------------------------------------------------------------------
-
- virtual void SetFrame(const VRect& newFrame, Boolean invalidate);
- // Resizes the scroller to newFrame, redrawing if 'invalidate' is true.
-
-
- //------------------------------------------------------------------------------------
- // Location Methods
- //------------------------------------------------------------------------------------
-
- virtual void AdjustScrollLimits(Boolean drawScrollBars);
- // Adjust the scrolling limits and redraws the scroll bars.
-
- virtual void AdjustScrollBars(Boolean invalidate);
- // Resizes and re-Locates the scrollbars if required.
-
- virtual void SubViewChangedFrame(TView* theSubView,
- const VRect& oldFrame,
- const VRect& newFrame,
- Boolean invalidate);
- // Adjust the scroll limits based on the size change of the subviews.
-
- virtual void SetScrollLimits(const VPoint& scrollLimit,
- Boolean drawScrollBars);
- // Sets the scroll of the attached scrollbars, if there are any.
-
- virtual void SetScrollParameters(const VPoint& units,
- Boolean horzConstraint,
- Boolean vertConstraint);
- // Sets up the fScrollUnit and fConstrain fields of the scroller.
-
-
- //------------------------------------------------------------------------------------
- // Scrolling Methods
- //------------------------------------------------------------------------------------
-
- virtual void HaveScrollBar(TScrollerScrollBar* theScrollBar,
- VHSelect direction);
- // Sets the fScrollbar field in the given 'direction' to 'theScrollBar'.
-
- virtual void ScrollDraw(const VPoint& delta, Boolean invalidate);
- // Method responsible for actually doing the scrolling by calling moving bits.
- // Called by DoScroll.Invalidates newly revealed area if invalidate is true else
- // updates the redraws the newly revealed area if invalidate is false. !!! NOTE
- // this does not match the behaviour of other invalidate parameters because they
- // interpret invalidate equals false to neither draw nor invalidate.Well we
- // already know that the way that invalidate/ redraw/ don't-render control is
- // handled needs _MAJOR_ overhauling anyways Sigh!
-
- virtual void DoScroll(const VPoint& delta, Boolean redraw);
- // Method responsible for handling the scrolling, calls ScrollDraw if required.
-
- virtual VCoordinate ScrollStep(VHSelect vhs, short partCode);
- // Depending on the 'partCode' returns the amount to be scrolled.
-
- virtual VCoordinate ScrollRelative(VHSelect vhs, VCoordinate sBarValue);
- // Returns the relative amount to scroll.
-
- virtual void ScrollBy(const VPoint& delta, Boolean redraw);
- // Called to scroll by 'deltaH & 'deltaV'.
-
- virtual void SetLocalOrigin(const VPoint& newOrigin, Boolean redraw);
- // Sets the local origin. Preserves bits by scrolling to the required coordinates.
- // Calls ScrollBy
-
- virtual void AutoScroll(const VPoint& viewPt, VPoint& delta);
- // Called during auto scrolling to return the delta to be scrolled.
-
- virtual void RevealRect(const VRect& rectToReveal,
- const VPoint& minToSee,
- Boolean redraw);
- // Shows 'rectToReveal' with the minimum amount to be seen set to 'minToSee' by
- // calling ScrollBy.
-
- #if qDrag
-
- virtual VPoint GetDragScrollDelta(const VPoint& mouseInWindow);
-
- #endif
-
-
- //------------------------------------------------------------------------------------
- // Miscellaneous Methods
- //------------------------------------------------------------------------------------
-
- virtual void DoKeyEvent(TToolboxEvent* event);
- // Handles when the Home, End, PageUp & PageDown keys are used.
-
- virtual TScroller* GetScroller(Boolean immediateSuperView);
- // Returns this.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
-
- VRect fSBarOffsets; // how much to offset the associated
- // scroll bars from my bounds
-
- VPoint fScrollLimit; // the 'limit' of the subviews that should
- // be scrollable
-
- VPoint fMaxTranslation; // the computed maximum amount of
- // translation taking into account the
- // visible portion of the view. This keeps
- // us from scrolling the bottom of a view
- // to the top of a window
-
- VPoint fScrollUnit; // increment of scroll
-
- TScrollerScrollBar* fScrollBars[2]; // associated scroll bars if any
-
- IDType fScrollBarIdentifiers[2]; // associated scroll bars ids if any
-
- Boolean fConstrain[2]; // should scrolling be constrained to a
- // multiple of my scrollunit
-
- Boolean fRespondsToFunctionKeys; // if it responds to PgUp/ PgDn, etc.
-
- };
-
-
-
- #endif
-
-
-